From: Matthieu Gallien Date: Fri, 6 Jun 2025 09:58:39 +0000 (+0200) Subject: fix(crash): debug builds would not try to remove a not found job X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1^2~13^2~1^2~4^2 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=d5c9806896deef6d365bca5dbfe251ff0b7934ac;p=nextcloud-desktop.git fix(crash): debug builds would not try to remove a not found job in release builds we would happily try to remove an element from QList with invalid index (-1) if the job is not found avoid doing this in release builds and keep teh assert in debug builds Signed-off-by: Matthieu Gallien --- diff --git a/src/libsync/owncloudpropagator.cpp b/src/libsync/owncloudpropagator.cpp index bd597dee8..fba85c539 100644 --- a/src/libsync/owncloudpropagator.cpp +++ b/src/libsync/owncloudpropagator.cpp @@ -1293,9 +1293,11 @@ void PropagatorCompositeJob::slotSubJobFinished(SyncFileItem::Status status) // Delete the job and remove it from our list of jobs. subJob->deleteLater(); - int i = _runningJobs.indexOf(subJob); - Q_ASSERT(i >= 0); // should only happen if this function is called more than once - _runningJobs.remove(i); + const auto i = _runningJobs.indexOf(subJob); + Q_ASSERT(i >= 0 && i < _runningJobs.size()); // should only happen if this function is called more than once + if (i >= 0 && i < _runningJobs.size()) { + _runningJobs.remove(i); + } // Any sub job error will cause the whole composite to fail. This is important // for knowing whether to update the etag in PropagateDirectory, for example.